// import Card from "../../palette/card";
import LocalLife from "../../palette/localLife";

Page({
    data: {
        template: {},
        image: "",
        width: 750,
        height: 1200,
        code: "https://gips3.baidu.com/it/u=3557221034,1819987898&fm=3028&app=3028&f=JPEG&fmt=auto?w=1280&h=960",
        askName: "周某",
        askAvatar: "https://gips3.baidu.com/it/u=3557221034,1819987898&fm=3028&app=3028&f=JPEG&fmt=auto?w=1280&h=960",
        answerName: "老师",
        answerAvatar: "https://gips3.baidu.com/it/u=3557221034,1819987898&fm=3028&app=3028&f=JPEG&fmt=auto?w=1280&h=960",
        askText: "问题问题问题问题问题问题问题问题问题问题问题问题问题问题",
        answerText: "答案答案答案答案答案答案答案答案答案答案答案答案答案答案答案答案答案答案答案答案答案答案答案答案答案答案答案答案答案答案答案答案答案答案答案答案答案答案答案答案答案答案答案",
        time: "2020_4_1",
    },

    onLoad() {
        this.getDraw();
        this.setData({
            template: new LocalLife().palette(),
        });
        console.log(this.data.template);
    },

    getDraw() {
        wx.showLoading({
            title: "正在努力生成中",
        });
    },
    // 生成成功
    canvasSuc(e) {
        console.log(e);
        wx.hideLoading();
        this.setData({
            image: e.detail.path,
        });
    },

    getSave() {
        wx.saveImageToPhotosAlbum({
            filePath: this.data.image,
            success: (res) => {
                wx.showToast({
                    title: "保存成功",
                });
            },
        });
        wx.getSetting({
            success: (set) => {
                if (set.authSetting["scope.writePhotosAlbum"] == false) {
                    wx.openSetting();
                }
            },
        });
    },

    previewImg() {
        wx.previewImage({
            current: this.data.image,
            urls: [this.data.image],
        });
    },
});